#region (c) 2014 THN Solutions LLC. - All rights reserved
/*
Simplified BSD License (BSD)
Copyright (c) 2014, THN Solutions LLC. ( www.ThnSolutions.com )
Author: Nguyễn, M. Hải                 ( www.Minh-Hai.com     )
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this 
      list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
      this list of conditions and the following disclaimer in the documentation 
      and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.
*/
#endregion

#region Record of Change
//             							CHANGE HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | DEVELOPER  | DESCRIPTION                                              |
// -------------------------------------------------------------------------------------
// | 12-Nov-09 | HaiNM      | First creation.                                          |
// -------------------------------------------------------------------------------------
//
#endregion

#region Record of Audit
//             							REVIEW HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | REVIEWER   | NOTES                                                    |
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
//
#endregion

#region Using directives
using System;

using Thn;
using Thn.Interface.Vcl;
#endregion

namespace Demo
{
    /// <summary>
    /// 
    /// </summary>
#if DEBUG
    public
#else
    internal
#endif
 class HomePage : Page
    {
        private Line line1;
        private LinkLabel lblLogin;
        private LinkLabel lblEdit;
        private LinkLabel lblDummy;
        private LinkLabel lblInvalid;
        private LinkLabel lblMany;
        private Label label2;
        private LinkLabel lblSecured;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label lblStatus;
        private IconBox ibWarn;
        private IconBox iconBox1;
        private Blinker blinker;
        private Label label1;
        #region Fields
        #endregion

        #region Properties
        #endregion

        #region UI Events processing
        private void lblLogin_Click(object sender, EventArgs e)
        {
            Manager.Show("Login");
        }

        private void lblEdit_Click(object sender, EventArgs e)
        {
            Manager.Show("Edit");
        }

        private void lblSecured_Click(object sender, EventArgs e)
        {
            Manager.Show("AdminOnly");
        }

        private void lblDummy_Click(object sender, EventArgs e)
        {
            Manager.Show("Dummy");
        }

        private void lblInvalid_Click(object sender, EventArgs e)
        {
            Manager.Show("NOT EXISTING PAGE");
        }

        private void lblMany_Click(object sender, EventArgs e)
        {
            Manager.Show("Many1");
        }

        #region Shown
        private void HomePage_Shown(IPageManager manager, PageShowContext context)
        {
            //update status
            if (SecurityModel.IsAuthenticated)
            {
                #region Already logged in
                lblStatus.Text = string.Format("Hi, you're logged in with role {0}", SecurityModel.Role);
                lblStatus.TextStyle = TextStyle.Comment;
                ibWarn.Visible = false;
                #endregion
            }
            else
            {
                #region Not logged in
                lblStatus.Text = string.Format("You have not logged in yet");
                lblStatus.TextStyle = TextStyle.Warning;
                ibWarn.Visible = true;
                blinker.Blink();
                #endregion
            }
        }
        #endregion
        #endregion

        #region Initialize Component
        private void InitializeComponent()
        {
            this.label1 = new Thn.Interface.Vcl.Label();
            this.line1 = new Thn.Interface.Vcl.Line();
            this.lblLogin = new Thn.Interface.Vcl.LinkLabel();
            this.lblEdit = new Thn.Interface.Vcl.LinkLabel();
            this.lblDummy = new Thn.Interface.Vcl.LinkLabel();
            this.lblInvalid = new Thn.Interface.Vcl.LinkLabel();
            this.lblMany = new Thn.Interface.Vcl.LinkLabel();
            this.label2 = new Thn.Interface.Vcl.Label();
            this.lblSecured = new Thn.Interface.Vcl.LinkLabel();
            this.label3 = new Thn.Interface.Vcl.Label();
            this.label4 = new Thn.Interface.Vcl.Label();
            this.label5 = new Thn.Interface.Vcl.Label();
            this.label6 = new Thn.Interface.Vcl.Label();
            this.label7 = new Thn.Interface.Vcl.Label();
            this.lblStatus = new Thn.Interface.Vcl.Label();
            this.ibWarn = new Thn.Interface.Vcl.IconBox();
            this.iconBox1 = new Thn.Interface.Vcl.IconBox();
            this.blinker = new Thn.Interface.Vcl.Blinker();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(68, 17);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(384, 44);
            this.label1.TabIndex = 0;
            this.label1.Text = "This is home page";
            this.label1.TextStyle = Thn.Interface.Vcl.TextStyle.HeadingLarge;
            this.label1.Transparent = true;
            // 
            // line1
            // 
            this.line1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
            this.line1.Location = new System.Drawing.Point(14, 67);
            this.line1.Name = "line1";
            this.line1.Size = new System.Drawing.Size(511, 10);
            this.line1.TabIndex = 1;
            this.line1.Text = "line1";
            this.line1.Transparent = true;
            // 
            // lblLogin
            // 
            this.lblLogin.Location = new System.Drawing.Point(68, 204);
            this.lblLogin.Name = "lblLogin";
            this.lblLogin.Size = new System.Drawing.Size(120, 22);
            this.lblLogin.TabIndex = 1;
            this.lblLogin.Text = "Go to login page";
            this.lblLogin.Transparent = true;
            this.lblLogin.Click += new System.EventHandler(this.lblLogin_Click);
            // 
            // lblEdit
            // 
            this.lblEdit.Location = new System.Drawing.Point(68, 159);
            this.lblEdit.Name = "lblEdit";
            this.lblEdit.Size = new System.Drawing.Size(120, 22);
            this.lblEdit.TabIndex = 0;
            this.lblEdit.Text = "Go to edit page";
            this.lblEdit.Transparent = true;
            this.lblEdit.Click += new System.EventHandler(this.lblEdit_Click);
            // 
            // lblDummy
            // 
            this.lblDummy.Location = new System.Drawing.Point(68, 335);
            this.lblDummy.Name = "lblDummy";
            this.lblDummy.Size = new System.Drawing.Size(134, 22);
            this.lblDummy.TabIndex = 4;
            this.lblDummy.Text = "Go to dummy page";
            this.lblDummy.Transparent = true;
            this.lblDummy.Click += new System.EventHandler(this.lblDummy_Click);
            // 
            // lblInvalid
            // 
            this.lblInvalid.Location = new System.Drawing.Point(68, 380);
            this.lblInvalid.Name = "lblInvalid";
            this.lblInvalid.Size = new System.Drawing.Size(161, 22);
            this.lblInvalid.TabIndex = 5;
            this.lblInvalid.Text = "Go to a non-existing page";
            this.lblInvalid.Transparent = true;
            this.lblInvalid.Click += new System.EventHandler(this.lblInvalid_Click);
            // 
            // lblMany
            // 
            this.lblMany.Location = new System.Drawing.Point(68, 291);
            this.lblMany.Name = "lblMany";
            this.lblMany.Size = new System.Drawing.Size(205, 22);
            this.lblMany.TabIndex = 3;
            this.lblMany.Text = "Go to a page with lots of controls";
            this.lblMany.Transparent = true;
            this.lblMany.Click += new System.EventHandler(this.lblMany_Click);
            // 
            // label2
            // 
            this.label2.Alignment = System.Drawing.ContentAlignment.TopLeft;
            this.label2.Location = new System.Drawing.Point(302, 159);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(223, 36);
            this.label2.TabIndex = 5;
            this.label2.Text = "Example of handling content modifications";
            this.label2.Transparent = true;
            // 
            // lblSecured
            // 
            this.lblSecured.Location = new System.Drawing.Point(68, 248);
            this.lblSecured.Name = "lblSecured";
            this.lblSecured.Size = new System.Drawing.Size(145, 22);
            this.lblSecured.TabIndex = 2;
            this.lblSecured.Text = "Go to a secured page";
            this.lblSecured.Transparent = true;
            this.lblSecured.Click += new System.EventHandler(this.lblSecured_Click);
            // 
            // label3
            // 
            this.label3.Alignment = System.Drawing.ContentAlignment.TopLeft;
            this.label3.Location = new System.Drawing.Point(302, 204);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(223, 36);
            this.label3.TabIndex = 5;
            this.label3.Text = "Example of implementing a security authentication";
            this.label3.Transparent = true;
            // 
            // label4
            // 
            this.label4.Alignment = System.Drawing.ContentAlignment.TopLeft;
            this.label4.Location = new System.Drawing.Point(302, 248);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(223, 25);
            this.label4.TabIndex = 5;
            this.label4.Text = "Only admin user can view this page";
            this.label4.Transparent = true;
            // 
            // label5
            // 
            this.label5.Alignment = System.Drawing.ContentAlignment.TopLeft;
            this.label5.Location = new System.Drawing.Point(302, 291);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(223, 36);
            this.label5.TabIndex = 5;
            this.label5.Text = "Demonstrate the speed of VCL v2";
            this.label5.Transparent = true;
            // 
            // label6
            // 
            this.label6.Alignment = System.Drawing.ContentAlignment.TopLeft;
            this.label6.Location = new System.Drawing.Point(302, 335);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(223, 36);
            this.label6.TabIndex = 5;
            this.label6.Text = "Example of children pages and parent page";
            this.label6.Transparent = true;
            // 
            // label7
            // 
            this.label7.Alignment = System.Drawing.ContentAlignment.TopLeft;
            this.label7.Location = new System.Drawing.Point(302, 380);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(223, 36);
            this.label7.TabIndex = 5;
            this.label7.Text = "Error example";
            this.label7.Transparent = true;
            // 
            // lblStatus
            // 
            this.lblStatus.Location = new System.Drawing.Point(68, 98);
            this.lblStatus.Name = "lblStatus";
            this.lblStatus.Size = new System.Drawing.Size(231, 22);
            this.lblStatus.TabIndex = 6;
            this.lblStatus.Text = "You have not logged in";
            this.lblStatus.TextStyle = Thn.Interface.Vcl.TextStyle.Comment;
            this.lblStatus.Transparent = true;
            // 
            // ibWarn
            // 
            this.ibWarn.IconStyle = Thn.Interface.Vcl.IconStyle.Warning;
            this.ibWarn.Location = new System.Drawing.Point(28, 89);
            this.ibWarn.Name = "ibWarn";
            this.ibWarn.Size = new System.Drawing.Size(37, 37);
            this.ibWarn.TabIndex = 7;
            this.ibWarn.Text = "iconBox1";
            this.ibWarn.Transparent = true;
            // 
            // iconBox1
            // 
            this.iconBox1.IconStyle = Thn.Interface.Vcl.IconStyle.Home;
            this.iconBox1.Location = new System.Drawing.Point(14, 13);
            this.iconBox1.Name = "iconBox1";
            this.iconBox1.Size = new System.Drawing.Size(50, 48);
            this.iconBox1.TabIndex = 7;
            this.iconBox1.Text = "iconBox1";
            this.iconBox1.Transparent = true;
            // 
            // blinker
            // 
            this.blinker.Duration = 1000;
            this.blinker.Target = this.ibWarn;
            // 
            // HomePage
            // 
            this.BackgroundImage = global::PageDemo.Properties.Resources.Page_Content;
            this.Controls.Add(this.iconBox1);
            this.Controls.Add(this.ibWarn);
            this.Controls.Add(this.lblStatus);
            this.Controls.Add(this.lblSecured);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.lblMany);
            this.Controls.Add(this.lblInvalid);
            this.Controls.Add(this.lblDummy);
            this.Controls.Add(this.lblEdit);
            this.Controls.Add(this.lblLogin);
            this.Controls.Add(this.line1);
            this.Controls.Add(this.label1);
            this.Name = "HomePage";
            this.Size = new System.Drawing.Size(755, 580);
            this.Shown += new Thn.Interface.Vcl.PageShownHandler(this.HomePage_Shown);
            this.ResumeLayout(false);

        }
        #endregion

        #region Constructors
        /// <summary>
        /// Default constructor.
        /// </summary>
        public HomePage()
        {
            InitializeComponent();
        }
        #endregion
    }
}
